package com.york.subject.common.enums;

import lombok.Getter;

/**
 * 题目类型枚举，为了配合工厂设计模式使用
 * 根据枚举返回的code，返回设计好的相关的工厂，比如返回code1就返回单选题的工厂
 * 1单选 2多选 3判断 4简答
 */
@Getter
public enum SubjectInfoTypeEnum {

    RADIO(1, "单选"),
    MULTIPLE(2, "多选"),
    JUDGE(3, "判断"),
    BRIEF(4, "简答");

    public final int code;

    public final String desc;

    SubjectInfoTypeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static SubjectInfoTypeEnum getByCode(int codeVal) {
        for (SubjectInfoTypeEnum subjectInfoTypeEnum : SubjectInfoTypeEnum.values()) {
            if (subjectInfoTypeEnum.code == codeVal) {
                return subjectInfoTypeEnum;
            }
        }
        return null;
    }
}


